#define DEBUG
#include <cstdio>
#include <algorithm>

using namespace std;

const int maxn=1000000, maxm=100000;

int max(int a, int b) {
  return a>b ? a : b;
}

class Ele {
public:
  int a, b;
  
  static bool cmp(Ele a, Ele b) {
    return a.a<b.a || (a.a==b.a && a.b>b.b);
  }
};

int main() {
  freopen("backpack.in", "r", stdin);
  freopen("backpack.out", "w", stdout);

  static int a[maxn+1], b[maxn+1], f[maxm+1];
  static Ele ta[maxn+1];
  int n;
  long long m;
  scanf("%d %lld", &n, &m);
  for (int i=1; i<=n; i++) {
    scanf("%d %d", &ta[i].a, &ta[i].b);
  }
  sort(ta+1, ta+n+1, Ele::cmp);

  int tn = n;
  n = 0;
  for (int i=1; i<=tn; i++) {
    if (ta[i].a!=a[n]) {
      n++;
      a[n] = ta[i].a;
      b[n] = ta[i].b;
    }
  }

  int s=1;
  long double sv=(long double)b[s]/a[s];
  for (int i=1; i<=n; i++) {
    long double tv=(long double)b[i]/a[i];
    if (tv>sv || (tv==sv && a[i]<a[s])) {
      s = i, sv = tv;
    }
  }

  for (int i=1; i<=m%a[s]; i++) {
    for (int j=1; j<=n; j++) {
      if (i>=a[j]) {
	f[i] = max(f[i], f[i-a[j]]+b[j]);
      }
    }
  }

  printf("%lld", f[m%a[s]]+b[s]*(m/a[s]));

  fclose(stdin);
  fclose(stdout);
  return 0;
}
